<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var person={
        personName:"zhangsan",
        age:20,
        sayHello:function(){
            console.log("hello");

        }
    }
    //第一个写法 最常用的写法 对象.属性名
    //对象.方法名
    console.log(person.age);
    console.log(person.sayHello());
    //第二种写法 对象["属性名"]
    console.log(person["personName"]);
    person["sayHello"]();
    //区别 对象[变量]中括号中可以放变量
    var attr="age";
    console.log(person[attr]);
    //访问对象不存在的属性 打印是undefined
    console.log(person.hobby);
    person.hobby=["swimming","football"];
    console.log(person);
    //添加一个weight
    person["weight"]=90;
    console.log(person);
    //修改属性值
    person.age=30;
    person["age"]=30;
    delete person.age;
    console.log(person.age);
    </script>
</html>